<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <script type="text/javascript" src="../script/config.js"></script>
    <style>
        header{ background-color: #f16c3c; line-height: 42px; height: 42px; position: relative;padding-top:22px;}
        header b{ width: 42px; height:42px; display: inline-block; position: relative; z-index: 1; background: url() no-repeat center; background-size: 70% auto;  }
        header b.ic-back{ background-image: url(../image/back.png);background-size:25px 25px;}
        header b.ic-check{ background-image: url(../image/scan_a_QR_code.png); float: right;margin-right:10px;}
        header .title{ position: absolute; left: 0; bottom: 0; right: 0;  text-align: center; font-size: 18px;color:white;}
        #foot{
          position:relative;;
          margin:10%;
          width:90%;
          height:50px;
          bottom:0;
          left:0;
          font-size:18px;
        }
        .foot_sure{
          padding-left:17%;
          padding-right:17%;
          padding-top:10px;
          padding-bottom:10px;
          background-color:#f16c3c;
          color:white;
          border-radius:10px;
        }
        .foot_cancle{
          padding-left:17%;
          padding-right:17%;
          padding-top:10px;
          padding-bottom:10px;
          background-color:#f16c3c;
          color:white;
          border-radius:10px;
        }
    </style>
</head>
<body>
    <div id="wrap" class="flex-wrap flex-vertical" >
        <header class="border-b" >
            <b tapmode="hover" onclick="api.closeWin();" class="ic-back"></b>
            <div class="title" id="title"></div>
            <b tapmode="hover" onclick="funActionSheet();"  class="ic-check"></b>
        </header>
        <div id="main" class="flex-con" >

        </div>

    </div>
</body>
</html>
<script type="text/javascript" src="../script/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<!-- <script type="text/javascript" src="../script/up_check.js"></script> -->
<script type="text/javascript">
    apiready = function(){
      $api.text($api.dom("#title"),api.pageParam.name);
        api.openFrame({
            name: 'wait_schedulings',
            url: './wait_schedulings.html',
            rect: {
                x: 0,
                y: $api.dom('header').offsetHeight,
                w: api.winWidth,
                h: $api.dom('#main').offsetHeight
            },
            pageParam: {
                  name:api.pageParam.name
                    }
});



}
var upload_map=function(id){
  // alert(1)
  var bMap = api.require('bMap');
  bMap.getLocation({
      accuracy: '10m',
      autoStop: true,
      filter: 1
  }, function(ret, err) {
      if (ret.status) {
        $api.post(url+'app.php/scmap',{
         body:{
              lorryid:id,
              longitude:ret.lon,
              latitude:ret.lat,
              }
         },function(ret){
        //  alert(ret.desc);
       },'json');
      } else {
          // alert(err.code);
      }
  });
}
var check=function(id,time){
  $api.post(url+'app.php/check',{
        body:{lorryid:id,
              time:time,}
       },function(ret){
        if(ret.result==4){
          alert(ret.desc);
          api.openWin({
            name: 'index',
            url:  '../index.html',
          });
           setTimeout("api.closeWin({name:'main'})",650);
           $api.rmStorage('password');
           var key = 'user';
           var user = {};
           var aa=$api.getStorage(key);
           user.lorryid=aa.lorryid;
            user.telephone=aa.telephone;
           user.flag= aa.flag
           user.pass= '';
           $api.setStorage(key, user);
           api.alert({
             title: '提示消息',
             msg: ret.desc,
             buttons: ['确定']
           });
         }else{
          //  alert(ret.desc);
         }
       });



}
var funActionSheet=function(){
  var user = $api.getStorage('user');
  var lorryid=user.lorryid;
  var time=user.time;
  var name=api.pageParam.name;
//     var scanner = api.require('scanner');
// scanner.open(function(ret, err) {
    // if (ret.msg) {
    var FNScanner = api.require('FNScanner');
FNScanner.openScanner({
autorotation: true
}, function(ret, err) {
if(ret.content){
      $api.append($api.dom('body'), '<audio src="../image/Win.mp3" controls="controls" preload id="music1" hidden>');
      $api.dom('#music1').play();
      api.openWin({
        name: 'scheduling_main',
        url:  './scheduling_main.html',
        pageParam: {
          name:name,
          scheduling_id:ret.content,
        }
      });
      // var scanner = api.require('scanner');
      // scanner.closeview();
        // alert(JSON.stringify(ret.msg));
        var FNScanner = api.require('FNScanner');
         FNScanner.closeView();
    } else {
      // var scanner = api.require('scanner');
      // scanner.closeview();
        // alert(JSON.stringify(err));
        var FNScanner = api.require('FNScanner');
          FNScanner.closeView();
    }
  });
check(lorryid,time);
}
</script>
